#include <bits/stdc++.h>
using namespace std;

int main() {

// (2^x) - 1
    int n;
    while(cin >> n)
    {
        int m = 1;
        while(m - 1 <= n)
        {
            m *= 2;
        }
        cout << (m / 2 - 1) << endl;
    }
    return 0;
}